﻿package com.guavestudios.fcon.util {
	import flash.ui.Keyboard;
	
	/**
	* ...
	* @author Default
	*/
	public class KeyUtil {
		
		public static const CHAR_TOKEN:String = "Char.";
		public static const KEY_TOKEN:String = "Key.";
		private static const NUMBER_REG:RegExp=/^\d{1,3}$/;
		
		public static function parseKey(key:String):int
		{
			var keyc:int=0;
			if (key.indexOf(CHAR_TOKEN)>-1)
			{
				keyc = -parseInt(key.substr(CHAR_TOKEN.length));
			}
			else if (key.indexOf(KEY_TOKEN)>-1)
			{
				keyc = Keyboard[key.substr(KEY_TOKEN.length)];
			}
			else if (NUMBER_REG.test(key))
			{
				keyc = parseInt(key);
			}
			return keyc;
		}
		public function KeyUtil() {
			
		}
		
	}
	
}